package typoker.logic;

public final class Card {
	public static final String[] suits = {"Clubs", "Spades", "Hearts", "Diamonds"};
	public static final String[] ranks = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"};
	public static final int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41};
	
	private final byte suit;
	private final byte rank;
	private final int value;
	
	public Card(byte suit, byte rank) {
		this.suit = suit;
		this.rank = rank;
		this.value = calculateValue(suit, rank);
	}
	
	private int calculateValue(int suit, int rank) {
		suit = 0x8000 >>> suit;
		return primes[rank] | (rank << 8) | suit | (1 << (16 + rank));
	}

	public int getValue() {
		return value;
	}
	
	public String getImage() {
		return "" + ranks[rank].charAt(0) + suits[suit].charAt(0) + ".png";
	}

	@Override
	public String toString() {
		return ranks[rank] + " of " + suits[suit];
	}
}